const router = require('koa-router')()
const { resolve } = require('path')
const glob = require('glob')

// 加载所有路由
glob.sync(resolve(__dirname, '../routes', '**/*.js')).forEach(item => {
  require(item)(router)
})

module.exports = app => {
  app.use(router.routes())
  app.use(router.allowedMethods())
}